//
//  YHYEditingPersonViewController.m
//  Home
//
//  Created by 杨泓晔 on 16/6/17.
//  Copyright © 2016年 LanJue. All rights reserved.
//

#import "YHYEditingPersonViewController.h"
#import "WSAddCVItemTwo.h"
#import "WSAddLineView.h"
#import "WSAddCVHeadView.h"
#import "WSAddWorkHeadView.h"
#import "WSAddCVItem.h"
#import "WSAddCVTypeSubCell.h"
#import "WSAddCVModel.h"
#import "DCPaymentView.h"
#import "YHYStyleCollectionCell.h"//风格
#import "YHYJobCollectionCell.h"//添加item
#import "DCPaymentView.h"//提示输入价钱
#import "WSCustomPickerView.h"
#import "YHYAddWorkViewController.h"//添加工作经历
#import "YHYAddStudyViewController.h"//添加教育背景
#import "YHYSaveButtonCollectionViewCell.h"//button保存

@interface YHYEditingPersonViewController ()<UICollectionViewDataSource,UICollectionViewDelegate,YHYStyleDetail,WSCustomPickerViewDelegate,YHYAddStudyDelegate,YHYAddWorkDelegate,seaveDeleate>
{
    NSInteger a;
    NSMutableDictionary *paramerse;
    YHYStyleCollectionCell *cell3;
    NSMutableArray * cell3Array;

    
}
@property (nonatomic, strong) UICollectionView *collectionView;
@property (nonatomic, strong) NSMutableArray *keyArr;
@property (nonatomic, strong) NSMutableArray *cellArr;
@property (nonatomic, strong) WSAddCVModel *model;
@property (nonatomic, strong) WSCustomPickerView *customPicker;
@property (nonatomic, strong) NSMutableArray *addSchool;
@property (nonatomic, strong) NSMutableArray *addCompany;


/**
 * 我的职业六个item
 */
@property (nonatomic, strong) NSMutableArray *Arr;
/**
 * 我的亮点添加item
 */
@property (nonatomic, strong) NSMutableArray *ArrTwo;
/**
 *  我的亮点数组
 */
@property (nonatomic, strong) NSMutableArray *myBright;
/**
 * 擅长风格添加item
*/
@property (nonatomic, strong) NSMutableArray *ArrThree;
/**
 *  擅长风格
 */
@property (nonatomic, strong) NSMutableArray *myStyle;

@property (nonatomic, strong) NSString *price;

@property (nonatomic, strong) NSString *addressStr;




@property (nonatomic, strong) NSIndexPath *indexPath;
@property (nonatomic, strong) NSIndexPath *indexPath2;

@property (nonatomic, strong) NSString *age;
@end

@implementation YHYEditingPersonViewController



- (void)viewWillAppear:(BOOL)animated {
    
    self.navigationController.navigationBarHidden = NO;
    self.tabBarController.tabBar.hidden=YES;
    
    self.title = @"个人信息";
    
}

-(void) viewWillDisappear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden=NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //数据plist
    [self initData];
//    [self AFNetWorking];
    
    paramerse =[ NSMutableDictionary new ];
    [paramerse setObject:[LOCALSEVE objectForKey:@"UID"] forKey:@"uid"];
    [paramerse setObject:[LOCALSEVE objectForKey:@"MCODE"] forKey:@"mcode"];
//    [paramerse setObject:@1 forKey:@"id"];
    // Do any additional setup after loading the view.
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back"] style:UIBarButtonItemStylePlain target:self action:@selector(Back:)];
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor whiteColor];
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    // flowLayout.minimumInteritemSpacing = 0;
    
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 40) collectionViewLayout:flowLayout];
    self.collectionView.showsVerticalScrollIndicator = NO;
    self.collectionView.backgroundColor = [UIColor whiteColor];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    [self.view addSubview:_collectionView];
    
    //添加教育
    [self.collectionView registerClass:[WSAddCVItem class] forCellWithReuseIdentifier:@"WSAddCVItem"];
    [self.collectionView registerClass:[WSAddCVItem class] forCellWithReuseIdentifier:@"WSAddCVItem2"];
    [self.collectionView registerClass:[WSAddCVItemTwo class] forCellWithReuseIdentifier:@"addCVItem"];
    
    
    
    [self.collectionView registerClass:[WSAddCVHeadView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"addHeadView"];
    [self.collectionView registerClass:[WSAddWorkHeadView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"addWorkHeadView"];
    // 注册表头区域
    [self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header"];
    // 注册底部区域
    [self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"footer"];
    
    [self.collectionView registerClass:[WSAddCVTypeSubCell class] forCellWithReuseIdentifier:@"selectCell"];
    
    [self.collectionView registerClass:[YHYJobCollectionCell class] forCellWithReuseIdentifier:@"cell"];
    //风格
    [self.collectionView registerClass:[YHYStyleCollectionCell class] forCellWithReuseIdentifier:@"YHYStyleCollectionCell"];
    
    //保存
    [self.collectionView registerClass:[YHYSaveButtonCollectionViewCell class] forCellWithReuseIdentifier:@"YHYSaveButtonCollectionViewCell"];
    
   
    [_collectionView reloadData];
    
    
    _Arr = [NSMutableArray array];
    _ArrTwo = [NSMutableArray array];
    _myBright = [NSMutableArray arrayWithObjects:@"室内设计",@"工装设计",@"软装设计",@"3D设计",@"建筑设计",@"园林设计", nil];
    _addSchool = [NSMutableArray array];
    _addCompany = [NSMutableArray array];
    
}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    /**
     *  区0
     */
    [self getAFNetingUrl];

    if (indexPath.section == 0) {
#pragma mark 我的职业 6个item赋值
        WSAddCVTypeSubCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"selectCell" forIndexPath:indexPath];
        
        NSDictionary *dic = [_cellArr[0] firstObject];
        NSString *titleStr = [[dic allKeys] firstObject];
        NSArray *array = [dic objectForKey:titleStr];
        cell.contentStr = [array objectAtIndex:indexPath.row];
        
        if (_Arr != nil) {
            
            
            if ([_Arr containsObject:cell.contentStr]) {
                
                [cell changeColor:YES];
            } else {
                [cell changeColor:NO];
            }
            
        }
        
        
        
        return cell;
        
    }
    
    
    /**
     *  区2 我的亮点
     */
    if (indexPath.section == 2) {
        YHYJobCollectionCell *cell2 = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
        cell2.image.hidden = YES;
        //cell.contentStr = [_myBright objectAtIndex:indexPath.row];
        if (indexPath.row != _myBright.count ) {
            cell2.contentStr = [_myBright objectAtIndex:indexPath.row];
            cell2.image.hidden = YES;
            
            if (_ArrTwo != nil) {
                
                if ([_ArrTwo containsObject:cell2.contentStr]) {
                    
                    [cell2 changeColor:YES];
                } else {
                    
                    [cell2 changeColor:NO];
                }
                
            }
            
             NSLog(@"2222222222=%@",_ArrTwo);
            NSLog(@"33333333333=%@",cell2.contentStr);

        }
        else{
            cell2.num = 2;
            
        }
        
        
        
        return cell2;

    }
    //风格
    if (indexPath.section == 3) {
       cell3 = [collectionView dequeueReusableCellWithReuseIdentifier:@"YHYStyleCollectionCell" forIndexPath:indexPath];
        [cell3 setSelectArr:cell3Array];
        cell3.deleagte = self;
        return cell3;
    }
    if (indexPath.section == 4) {//添加工作经历
        WSAddCVItem *cell4 = [collectionView dequeueReusableCellWithReuseIdentifier:@"WSAddCVItem" forIndexPath:indexPath];
        if (_addCompany.count == 0) {
            cell4.addLabel.text = @"+添加工作经历";
        }
        else{
            cell4.addLabel.text = [_addCompany objectAtIndex:indexPath.row];
        }
        
                return cell4;
    }
    if (indexPath.section == 5) {
        WSAddCVItem *cell5 = [collectionView dequeueReusableCellWithReuseIdentifier:@"WSAddCVItem2" forIndexPath:indexPath];
        if (_addSchool.count == 0) {
            cell5.addLabel.text = @"+添加教育经历";
//            NSInteger mun = indexPath.row;
//            [_addSchool insertObject:@"+添加教育经历" atIndex:mun];
//            [_addSchool removeAllObjects];
            
        }
        else{
        
            cell5.addLabel.text = [_addSchool objectAtIndex:indexPath.row];
            
            
        }
        
        return cell5;

    }
    if (indexPath.section == 6) {
        YHYSaveButtonCollectionViewCell *cellsave = [collectionView dequeueReusableCellWithReuseIdentifier:@"YHYSaveButtonCollectionViewCell" forIndexPath:indexPath];
        cellsave.Delegate = self;
        return cellsave;
    }

       else{
        WSAddCVItem *cell1 = [collectionView dequeueReusableCellWithReuseIdentifier:@"addCVItem" forIndexPath:indexPath];
 
        if (indexPath.section == 1) {
             cell1.type = 1;
            NSMutableArray *array = [_cellArr objectAtIndex:1];
            NSMutableDictionary *dic = array[indexPath.row];
            
            NSString *titleStr = [[dic allKeys] firstObject];
            cell1.titleStr = titleStr;
            if (indexPath.row == 0) {
                a = 0;//收取费用
                if (self.price != nil) {
                cell1.contentLabel.text = [NSString stringWithFormat:@"%@元",self.price];
                }
                else{
                    cell1.contentLabel.text = @"";
                }
            }
            if (indexPath.row == 1) {//地址
                a = 1;
               
                cell1.contentLabel.text = self.addressStr;
                
                
            }
            if (indexPath.row == 2) {//年限
                a = 2;
                if (self.age != nil) {
                    cell1.contentLabel.text = [NSString stringWithFormat:@"%@",self.age];
                }
                else{
                    cell1.contentLabel.text = @"";
                }
            }
            
            
        }
           
        
        
        return cell1;
    }
    
    
    return nil;
    
}
#pragma mark -- 协议
//擅长风格协议
- (void)presentnum{
    NSString *title = NSLocalizedString(@"提示", nil);
    NSString *message = NSLocalizedString(@"只能添加六个", nil);
    NSString *cancelButtonTitle = NSLocalizedString(@"取消", nil);
    NSString *otherButtonTitle = NSLocalizedString(@"确认", nil);
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancelButtonTitle style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
        
    }];
    
    UIAlertAction *otherAction = [UIAlertAction actionWithTitle:otherButtonTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
    }];
    
    [alertController addAction:cancelAction];
    [alertController addAction:otherAction];
    
    [self presentViewController:alertController animated:YES completion:nil];

}
-(void)postArray:(NSMutableArray *)imageNameArr{

    if (imageNameArr.count == 0) {
        
    }
    if (imageNameArr.count == 1) {
        [paramerse setObject:imageNameArr[0] forKey:@"style"];
    }
    if (imageNameArr.count == 2) {
        [paramerse setObject:[NSString stringWithFormat:@"%@,%@",imageNameArr[0],imageNameArr[1]] forKey:@"style"];

    }
    if (imageNameArr.count == 3) {
        [paramerse setObject:[NSString stringWithFormat:@"%@,%@,%@",imageNameArr[0],imageNameArr[1],imageNameArr[2]] forKey:@"style"];

    }
    if (imageNameArr.count == 4) {
   [paramerse setObject:[NSString stringWithFormat:@"%@,%@,%@,%@",imageNameArr[0],imageNameArr[1],imageNameArr[2],imageNameArr[3]] forKey:@"style"];
    }
    if (imageNameArr.count == 5) {
   [paramerse setObject:[NSString stringWithFormat:@"%@,%@,%@,%@,%@",imageNameArr[0],imageNameArr[1],imageNameArr[2],imageNameArr[3],imageNameArr[4]] forKey:@"style"];
    }
    if (imageNameArr.count == 6) {
   [paramerse setObject:[NSString stringWithFormat:@"%@,%@,%@,%@,%@,%@",imageNameArr[0],imageNameArr[1],imageNameArr[2],imageNameArr[3],imageNameArr[4],imageNameArr[5]] forKey:@"style"];
    }
    else {
    
    }
    

}
//选择器协议
- (void)sendAddressInfo:(NSString *)address{
    if (a == 1) {
      _addressStr = address;
    }
    
    
    if (a == 2) {
        
       // _age = address;
        NSLog(@"%@",address);
        NSDateFormatter* formatter = [[NSDateFormatter alloc]init];
        [formatter setDateFormat:@"YYYY-MM-dd"];
        NSString *date = [formatter stringFromDate:[NSDate date]];
        date = [date substringToIndex:4];
        address = [address substringToIndex:4];
        NSInteger age =  [address integerValue];
       
        
        if ([address integerValue] == 2005) {
            self.age  = [NSString stringWithFormat:@"10年以上"];
        }

        else{
                if (age == 0) {
                            self.age = [NSString stringWithFormat:@"2016"];
                        }
                else{
             self.age = [NSString stringWithFormat:@"%ld年", (long)age];
                }
        }

    }
       [_collectionView reloadItemsAtIndexPaths:@[_indexPath2]];
    if (self.age == 0) {
        
    }
    else {
    
        [paramerse setObject:[self.age componentsSeparatedByString:@"年"][0] forKey:@"exper"];
    
    }
    if (self.addressStr == nil) {
        
    }
    else{
        [paramerse setObject:[self.addressStr componentsSeparatedByString:@" "][0] forKey:@"province"];
        [paramerse setObject:[self.addressStr componentsSeparatedByString:@" "][1] forKey:@"city"];
        [paramerse setObject:[self.addressStr componentsSeparatedByString:@" "][2] forKey:@"area"];
        
    }
}

//学历协议
- (void)presentStudy:(NSString *)studyName{
    
    NSLog(@"%@",studyName);
    if (studyName.length != 0) {
     
    [_addSchool addObject:studyName];
    
    

    if (_addSchool.count == 1) {
        [_addSchool addObject:@"+添加教育经历"];
    }
    
   
    
    if (_addSchool.count > 2) {
        [_addSchool removeObject:@"+添加教育经历"];
        [_addSchool addObject:@"+添加教育经历"];
        
        
    }
    }
    else{
        //保存是传过来的数据是空时
    }
   
     [_collectionView reloadData];
}
//添加公司
- (void)presentAddWorkName:(NSString *)workName{
    NSLog(@"%@",workName);
    if (workName.length != 0) {
   
    [_addCompany addObject:workName];
    
    
    
    if (_addCompany.count == 1) {
        [_addCompany addObject:@"+添加工作经历"];
    }
    
    
    
    if (_addCompany.count > 2) {
        [_addCompany removeObject:@"+添加工作经历"];
        [_addCompany addObject:@"+添加工作经历"];
        
        
    }
    
    }
    else{
        //保存是传过来的数据是空时
    }
    [_collectionView reloadData];
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0) {
        
        NSDictionary *dic = [_cellArr[0] firstObject];
        NSString *titleStr = [[dic allKeys] firstObject];
        NSArray *array = [dic objectForKey:titleStr];
        NSString *str = [array objectAtIndex:indexPath.row];
        NSLog(@"%@",str);
        
        
        if ([_Arr containsObject:str]) { // 选择的 职业
            [_Arr removeObject:str];
        }
        else{
            if (_Arr.count < 3) {
                [_Arr addObject:str];
                
            }
            else{
        
            NSString *title = NSLocalizedString(@"提示", nil);
            NSString *message = NSLocalizedString(@"只能添加三个", nil);
            NSString *cancelButtonTitle = NSLocalizedString(@"取消", nil);
            NSString *otherButtonTitle = NSLocalizedString(@"确认", nil);
            UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancelButtonTitle style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
                
            }];
            
            UIAlertAction *otherAction = [UIAlertAction actionWithTitle:otherButtonTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
            }];
            
            [alertController addAction:cancelAction];
            [alertController addAction:otherAction];
            
            [self presentViewController:alertController animated:YES completion:nil];
            
        }
           // [_collectionView reloadItemsAtIndexPaths:@[indexPath]];

        }

        
        [_collectionView reloadItemsAtIndexPaths:@[indexPath]];
       
                if (_Arr.count == 0) {
        
                }
                if (_Arr.count == 1) {
                    [paramerse setObject:_Arr[0] forKey:@"jobtype"];
                }
                if (_Arr.count == 2) {
                    [paramerse setObject:[NSString stringWithFormat:@"%@,%@",_Arr[0],_Arr[1]] forKey:@"jobtype"];
        
                }
                if (_Arr.count == 3) {
                    [paramerse setObject:[NSString stringWithFormat:@"%@,%@,%@",_Arr[0],_Arr[1],_Arr[2]] forKey:@"jobtype"];
        
                }

        
                else{
        
                   
                
                }
        
    }
    
    if (indexPath.section == 1) {
        _indexPath2 = indexPath;
        /**
         *  收取费用
         */
        if (indexPath.row == 0) {
            a = 0;
            NSLog(@";wk;fwk");
            DCPaymentView *payAlert = [DCPaymentView new];
            //NSString *str = [_array objectAtIndex:indexPath.row+ 2 + indexPath.section];
            payAlert.numOfContent=5;
            payAlert.title = [NSString stringWithFormat:@"请输入费用"];
            [payAlert setTextFieldKeyBordToNum];
            [payAlert show];
            [payAlert setTextFieldKeyBordToNum];
            payAlert.completeHandle = ^(NSString *inputPwd) {
                
                //self.contentAry[indexPath.row] = inputPwd;
                self.price = inputPwd;  //收取费用
                [paramerse setObject:self.price forKey:@"price"];
            [_collectionView reloadItemsAtIndexPaths:@[indexPath]];
                
            };
        }
        if (indexPath.row == 1) {//地址
            a = 1;
            self.customPicker = nil;
            self.customPicker = [[WSCustomPickerView alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
            self.customPicker.delegate = self;
            self.customPicker.titleStr = @"任务地址";
            [self.view addSubview:_customPicker];
            [self.customPicker showPicker];
           
        //  [_collectionView reloadItemsAtIndexPaths:@[indexPath]];
            

        }
        if (indexPath.row == 2) {//年限
            a = 2;
            self.age = nil;
            self.customPicker = [[WSCustomPickerView alloc]initWithFrame:[[UIScreen mainScreen]bounds] type:1];
            self.customPicker.delegate = self;
            
            self.customPicker.titleStr = @"参加工作时间";
            [self.view addSubview:_customPicker];
            [self.customPicker showPicker];
//            if (self.age == nil) {
//                
//            }
//            else {
//            
//                [paramerse setObject:[self.age componentsSeparatedByString:@"年"] forKey:@"exper"];
//            
//            }
           // [_collectionView reloadItemsAtIndexPaths:@[indexPath]];
        }

        
    }
    if (indexPath.section == 4) {
        NSLog(@"添加工作案例");
        YHYAddWorkViewController *edit = [YHYAddWorkViewController new];
        edit.delegate = self;
        [self.navigationController pushViewController:edit animated:YES];
    }
    if (indexPath.section == 5) {
        YHYAddStudyViewController *study = [YHYAddStudyViewController new];
        study.delegate = self;
        [self.navigationController pushViewController:study animated:YES];
        
        if (indexPath.row == _addSchool.count - 1) {//添加案例
            NSLog(@"cdwc");
        }
    }
    
    
    /**
     *  点击我的亮点
     */
    if (indexPath.section == 2) {
        _indexPath = indexPath;
        YHYJobCollectionCell *cell = (YHYJobCollectionCell *)[collectionView cellForItemAtIndexPath:indexPath];
        if (indexPath.row == _myBright.count) {
            // [self addItem];
            DCPaymentView *payAlert = [[DCPaymentView alloc] init];
            payAlert.title = [NSString stringWithFormat:@"请输入"];
            payAlert.numOfContent = 7;
            [payAlert show];
            payAlert.completeHandle = ^(NSString *inputPwd) {
                [_myBright insertObject:inputPwd atIndex:_myBright.count ];
                [self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:_indexPath.section]];
                NSLog(@"last%@",[_ArrTwo lastObject]);
            };
             [_collectionView reloadItemsAtIndexPaths:@[indexPath]];

        }
        
        else{
            
            if ([_ArrTwo containsObject:cell.contentStr]) {
                [_ArrTwo removeObject:cell.contentStr];
            }
            else{
                
                if (_ArrTwo.count < 6) {
                    [_ArrTwo addObject:cell.myLabel.text];
                }
                else{
                
                
            
//            if (_ArrTwo.count >= 6) {
                NSString *title = NSLocalizedString(@"提示", nil);
                NSString *message = NSLocalizedString(@"只能添加六个", nil);
                NSString *cancelButtonTitle = NSLocalizedString(@"取消", nil);
                NSString *otherButtonTitle = NSLocalizedString(@"确认", nil);
                
                UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
                
                UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancelButtonTitle style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
                }];
                
                UIAlertAction *otherAction = [UIAlertAction actionWithTitle:otherButtonTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
                   
                }];
                
                // Add the actions.
                [alertController addAction:cancelAction];
                [alertController addAction:otherAction];
                
                [self presentViewController:alertController animated:YES completion:nil];
             
                    if (_ArrTwo.count == 0) {
                        
                    }
                    if (_ArrTwo.count == 1) {
                        [paramerse setObject:_ArrTwo[0] forKey:@"advantage"];
                    }
                    if (_ArrTwo.count == 2) {
                        [paramerse setObject:[NSString stringWithFormat:@"%@,%@",_ArrTwo[0],_ArrTwo[1]] forKey:@"advantage"];

                    }
                    if (_ArrTwo.count == 3) {
                       [paramerse setObject:[NSString stringWithFormat:@"%@,%@,%@",_ArrTwo[0],_ArrTwo[1],_ArrTwo[2]] forKey:@"advantage"];
                    }
                    if (_ArrTwo.count == 4) {
                        [paramerse setObject:[NSString stringWithFormat:@"%@,%@,%@,%@",_ArrTwo[0],_ArrTwo[1],_ArrTwo[2],_ArrTwo[3]] forKey:@"advantage"];
                    }
                    if (_ArrTwo.count == 5) {
                        [paramerse setObject:[NSString stringWithFormat:@"%@,%@,%@,%@,%@",_ArrTwo[0],_ArrTwo[1],_ArrTwo[2],_ArrTwo[3],_ArrTwo[4]] forKey:@"advantage"];
                    }
                    if (_ArrTwo.count == 6) {
                       [paramerse setObject:[NSString stringWithFormat:@"%@,%@,%@,%@,%@,%@",_ArrTwo[0],_ArrTwo[1],_ArrTwo[2],_ArrTwo[3],_ArrTwo[4],_ArrTwo[5]] forKey:@"advantage"];
                    }
                    else{
                    
                    }
                    
                    
                    
                
            }
            
            
           // [_collectionView reloadData];
          
 //[_collectionView reloadItemsAtIndexPaths:@[indexPath]];

    }
    
    
    
    
}
        
//        _ArrTwo   我的亮点
        
         [_collectionView reloadItemsAtIndexPaths:@[indexPath]];
        
        switch (_ArrTwo.count) {
            case 0:
                break;
                case 1:
                [paramerse setObject:_ArrTwo[0] forKey:@"advantage"];
                break;
                case 2:
                [paramerse setObject:[NSString stringWithFormat:@"%@,%@",_ArrTwo[0],_ArrTwo[1]] forKey:@"advantage"];
                break;
                case 3:
                 [paramerse setObject:[NSString stringWithFormat:@"%@,%@,%@",_ArrTwo[0],_ArrTwo[1],_ArrTwo[2]] forKey:@"advantage"];
                break;
                case 4:
                [paramerse setObject:[NSString stringWithFormat:@"%@,%@,%@,%@",_ArrTwo[0],_ArrTwo[1],_ArrTwo[2],_ArrTwo[3]] forKey:@"advantage"];
                break;
                case 5:
                 [paramerse setObject:[NSString stringWithFormat:@"%@,%@,%@,%@,%@",_ArrTwo[0],_ArrTwo[1],_ArrTwo[2],_ArrTwo[3],_ArrTwo[4]] forKey:@"advantage"];
                break;
                case 6:
                [paramerse setObject:[NSString stringWithFormat:@"%@,%@,%@,%@,%@,%@",_ArrTwo[0],_ArrTwo[1],_ArrTwo[2],_ArrTwo[3],_ArrTwo[4],_ArrTwo[5]] forKey:@"advantage"];
                break;
                
            default:
                break;
        }
    
}
}


-(void)postPersonInformation{

    NSString *url_string = [NSString stringWithFormat:@"%@%@",JIAFANURL,@"Gafaer/Home/CreateHome"];
    AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer.acceptableContentTypes = HTTPSET;
    [manager POST:url_string parameters:paramerse success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSLog(@"............%@",responseObject);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@",,,,,,,,,,,,%@",error);
        
    }];

}


- (void)addItem {
        
        DCPaymentView *payAlert = [[DCPaymentView alloc] init];
        payAlert.title = [NSString stringWithFormat:@"请输入"];
        payAlert.numOfContent = 7;
        [payAlert show];
        payAlert.completeHandle = ^(NSString *inputPwd) {
            [_ArrTwo insertObject:inputPwd atIndex:_ArrTwo.count ];
            
            [self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:_indexPath.section]];
            NSLog(@"last%@",[_ArrTwo lastObject]);
        };
        // [_collectionView reloadData];
    }




- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        
        return CGSizeMake(80 * AUTO_WIDTH, 30 * AUTO_HEIGHT);
        
    }
    if (indexPath.section == 2) {
        return CGSizeMake( 80 * AUTO_WIDTH, 30 * AUTO_HEIGHT);
    }
    if (indexPath.section == 3) {
        return CGSizeMake(SCREEN_WIDTH, 300 * AUTO_HEIGHT);
    }
    if (indexPath.section == 6) {
        return CGSizeMake(SCREEN_WIDTH, 70 * AUTO_HEIGHT);
    }
    
    
    return CGSizeMake(SCREEN_WIDTH, 50 * AUTO_HEIGHT);
    
}


- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    
 
    if (section == 0) {
        
        return UIEdgeInsetsMake(5 * AUTO_WIDTH, 135 / 4 * AUTO_WIDTH, 5 * AUTO_WIDTH, 135 / 4 * AUTO_WIDTH);
        
    }
    if (section == 2) {
        return UIEdgeInsetsMake(5 * AUTO_WIDTH, 135 / 4 * AUTO_WIDTH, 5 * AUTO_WIDTH, 135 / 4 * AUTO_WIDTH);


    }
    else{
        return UIEdgeInsetsZero;
    }
    
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    
    return _cellArr.count;
}

//item个数
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    if (section == 0) {
        return 6;
    }
    if (section == 1) {
        return 3;
    }
    if (section == 2) {
        
        return _myBright.count + 1;
        
    }
    if (section == 5) {
        if (_addSchool.count == 0) {
            return 1;
        }
        else{
        return _addSchool.count;
        }
    }
    if (section == 4) {
        if (_addCompany.count == 0) {
            return 1;
        }
        else{
            return _addCompany.count;
        }
    }
    return 1;
}


//第视图10
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section {
    //    if (section == _cellArr.count - 1 ) {
    //        return CGSizeMake(SCREEN_WIDTH,0);
    //    }
    return CGSizeMake(SCREEN_WIDTH, 10 * AUTO_HEIGHT);
}


// 设置头部和底部区域内容
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
    
    
    if (kind == UICollectionElementKindSectionHeader) {
        // 创建头部区域view
        WSAddWorkHeadView * headView = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"addWorkHeadView" forIndexPath:indexPath];
        headView.backgroundColor = [UIColor whiteColor];
        NSDictionary *dic = [_cellArr[indexPath.section] firstObject];
        NSString *titleStr = [[dic allKeys] firstObject];
        
        headView.titleStr = titleStr;
        
        
        
        return headView;
    }else{
        // 创建底部区域view
        UICollectionReusableView * footerView = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"footer" forIndexPath:indexPath];
        footerView.backgroundColor = LV;
        return footerView;
    }
    
    
}




- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
    
    
    return 5;
    
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
    
    //    if ((section == 1 && !(_isKid == ISKID)) || section >= _cellArr.count - 2) {
    //        NSLog(@"uuuu=%ld",_cellArr.count - 2);
    //        return CGSizeZero;
    //    }
    //    if (section == 5) {
    //        return CGSizeMake(SCREEN_WIDTH, 80);
    //    }
    
    if (section == 1) {
        return CGSizeMake(SCREEN_WIDTH, 0);
        
    }
    if (section == 4 || section == 5 || section == 6) {//＋添加工作经历 + 添加教育经历 + button
        return CGSizeMake(SCREEN_WIDTH, 0);

    }
    return CGSizeMake(SCREEN_WIDTH, 44);
}






#pragma mark -- 初始化数据
- (void)initData {
    
    _keyArr = [NSMutableArray arrayWithObjects:[NSArray arrayWithObjects:@"selfLabel", @"height", @"weight", @"employYear", @"country", nil], [NSArray arrayWithObjects:@"chest", @"waistline", @"hipMeasurement", @"shoeSize", nil], @"modelType", @"style", @"experience", @"temp", nil];
    NSString *nameStr = @"NModel";
    NSString *plistPath = [[NSBundle mainBundle] pathForResource:nameStr ofType:@"plist"];
    NSArray *tempArr = [[NSArray alloc] initWithContentsOfFile:plistPath];
    self.cellArr = [[NSMutableArray alloc] initWithArray:tempArr];
    NSMutableArray *firstArr = [NSMutableArray arrayWithArray:[tempArr objectAtIndex:3]];
    for (int i = 0; i < firstArr.count; i++) {
        NSDictionary *dic = firstArr[i];
        NSString *titleName = [[dic allKeys] firstObject];
        if ([titleName isEqualToString:@"擅长风格"] ||
            [titleName isEqualToString:@"商业摄影"] ||
            [titleName isEqualToString:@"影视妆"] ||
            [titleName isEqualToString:@"男装设计"]) {
            NSMutableArray *newArr = [NSMutableArray arrayWithArray:[[dic allValues] firstObject]];
            [firstArr removeObjectAtIndex:i];
            [firstArr insertObject:[NSMutableDictionary dictionaryWithObject:newArr forKey:titleName] atIndex:i];
        }
    }
    //    [self.cellArr removeObjectAtIndex:3];
    //    [self.cellArr insertObject:firstArr atIndex:3];
    
    
    
}
-(void)seavePost{


    [self postPersonInformation];

    
}
- (void)Back:(UIButton *)btu{
    [self.navigationController popViewControllerAnimated:YES];
}


-(void)getAFNetingUrl{

    NSLog(@"sssss%@",self.Mymodel);
//    NSMutableArray *jobArr = [self.Mymodel.jobtype componentsSeparatedByString:@","];
NSArray *arr =[self.Mymodel.jobtype componentsSeparatedByString:@","];
    if (arr.count == 0) {
        _Arr = [NSMutableArray arrayWithObjects:self.Mymodel.jobtype, nil];
    }
    else {
    
        _Arr = [NSMutableArray arrayWithArray:arr];
    }
    NSArray * ArrTwo = [self.Mymodel.advantage componentsSeparatedByString:@","];
    if (ArrTwo.count == 0) {
        _ArrTwo = [NSMutableArray arrayWithObject:self.Mymodel.advantage];
    }
    else{
    
        _ArrTwo = [NSMutableArray arrayWithArray:ArrTwo];
    
    }
    
    self.price = [NSString stringWithFormat:@"%@",self.Mymodel.price];
    self.addressStr = [NSString stringWithFormat:@"%@ %@ %@",self.Mymodel.province,self.Mymodel.city,self.Mymodel.area];
    self.age =  [NSString stringWithFormat:@"%@%@",self.Mymodel.exper,@"年"];
    
    NSArray * ArrThree = [self.Mymodel.style componentsSeparatedByString:@","];
    if (ArrThree.count == 0) {
        cell3Array = [NSMutableArray arrayWithObject:self.Mymodel.style];
    }
    else{
       
        cell3Array = [NSMutableArray arrayWithArray:ArrThree];
    }
   
   
    

}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
